from activist.Data import Data
from activist.MetaData import MetaData,MetaDataFactory

class GroupInformation(Data):

    def __init__(self,group,name,brief,description,url,creator=None):
                                        # do not serialize -- created by Group
        self._name = name
        self._brief = brief
        self._description = description
        self._url = url
        self.id()
        super(GroupInformation,self).__init__()

        if group:
            meta = MetaDataFactory(self,MetaData.InformationOf,group)
            if creator:
                MetaDataFactory(meta,MetaData.Creator,creator)

    def getXML(self):
        return """
<group class="activist.GroupInformation" id="%(id)s">
  <name>%(name)s</name>
  <description>%(description)s</description>
  <url>%(url)s</url>
%(meta)s
</group>
""" % { "id": self.id(),
        "name": self._name,
        "url": self._url,
        "description": self._description,
        "meta":self.getMetaXML()
        }

